package com.elitel.frame.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.elitel.frame.base.service.BaseRepdatasourceService;
import com.elitel.frame.main.dao.BaseRepdatasourceMapper;
import com.elitel.frame.main.dao.ext.ExtBaseRepdatasourceMapper;
import com.elitel.frame.main.entity.BaseRepdatasource;

@Service
public class BaseRepdatasourceServiceImpl implements BaseRepdatasourceService{
	
	@Autowired
	private BaseRepdatasourceMapper baseRepdatasourceMapper;
	@Autowired
	private ExtBaseRepdatasourceMapper extBaseRepdatasourceMapper;
	
	@Override
	public int insertBaseRepdatasource(List<BaseRepdatasource> list) {
		int size = 0;
		for (BaseRepdatasource baseRepdatasource : list) {
			size += baseRepdatasourceMapper.insertSelective(baseRepdatasource);
		}
		return size;
	}

	@Override
	public List<BaseRepdatasource> getReportDataSourceByServer(String serviceId) {
		List<BaseRepdatasource> list = extBaseRepdatasourceMapper.getReportDataSourceByServer(serviceId);
		return list;
	}

	@Override
	public int updateReportDataSource(List<BaseRepdatasource> list) {
		int size = 0;
		for (BaseRepdatasource baseRepdatasource : list) {
			size += baseRepdatasourceMapper.updateByPrimaryKeySelective(baseRepdatasource);
		} 
		return size;
	}

}
